package com.glut.campusrepair.controller;

import com.glut.campusrepair.dto.FailureRepairdto;
import com.glut.campusrepair.entity.FailureRepair;
import com.glut.campusrepair.service.IFailureRepairService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * 故障保修表 前端控制器
 *
 * @author sanminzhi
 * @since 2024-07-19 11:23
 */
@RestController
@CrossOrigin//支持跨域请求
@RequestMapping("/failure-repair")
public class FailureRepairController {

    private final IFailureRepairService failureRepairService;

    @Autowired
    IFailureRepairService iFailureRepairService;

    FailureRepairdto failureRepairdto;

    @Autowired
    public FailureRepairController(IFailureRepairService failureRepairService) {
        this.failureRepairService = failureRepairService;
    }

    @GetMapping("/list")
    public List<FailureRepair> getFailureRepairList() {
        // 这里调用Service层获取故障报修列表
        return failureRepairService.getFailureRepairList();
    }


    /**wsy
     * 根据故障报修ID查询相应报修的故障信息
     * 点击查看详情按钮后的操作
     * */
    @GetMapping("/getFailureRepairById")
    public FailureRepairdto getFailureRepairById(@RequestParam Integer failureRepairId) {
        failureRepairdto = iFailureRepairService.selectFailureRepairById(failureRepairId);
        return failureRepairdto;
    }
}
